package carrello.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class hiberutil  {
	
	    private static final SessionFactory sessionFactory = buildSessionFactory();
	
	    public static SessionFactory buildSessionFactory() {//throws Exception {
	        //try {
	            // Create the SessionFactory from hibernate.cfg.xml
	           return new AnnotationConfiguration().
                              setProperties(System.getProperties()).
                              configure("/hibernate.cfg.xml").
                              buildSessionFactory();
                    
	        //}
	        //catch (Exception ex) {
	            // Make sure you log the exception, as it might be swallowed
	            //System.err.println("Initial SessionFactory creation failed." + ex);
	            //throw new ExceptionInInitializerError(ex);
	    //    }//return null;
	    }

	    public static SessionFactory getSessionFactory( ) {
	        return sessionFactory;
	    }
            public static void main(String [] args) 
            {
                getSessionFactory();
            }

}
